<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="./jquery-1.4.4.js" type="text/javascript"></script>
<script>
	$(function(){
		$("#btn").click(function(){
			/*
			请求服务器 并解析服务器响应的 xml数据
			*/
			var h1_value = "";
			$.ajax({
				type:"GET",
				url:"<c:url value='/XmlServlet'/>",
				dataType:"xml",
				success:function(msg){
				//将XmlDocuemtn对象 $(msg)变为jquery对象 来操作
					$(msg).find("student").each(function(){
						var number = $(this).attr("number");
						var name = $(this).children("name").text();
						var age = $(this).children("age").text();
						var sex = $(this).children("sex").text();
						h1_value = number+", "+name+", "+age+", "+sex;
						$("#h1_id").text(h1_value);
					});
				},
			});
		
		
		});
	
	});



</script>
<title>Insert title here</title>
</head>
<body>
	<h1>服务器端响应 xml客户端来解析</h1>
	<button id="btn">点击这里</button>
	<h1 id="h1_id"></h1>
</body>
</html>